﻿using Model.Base;
using System.Collections.Generic;
using System.Data.Common;

namespace IDAL
{
    public interface IBaseADO<T> where T : class, new()
    {
        #region 增删改
        /// <summary>
        /// 根据主键id删除一条数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id"></param>
        /// <returns></returns>
        bool Delete(int id);
        /// <summary>
        /// 根据主键id逻辑删除一条数据(伪删除,需要传递删除标志字段以及相关值和需要同时修改的字段和字段值)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id"></param>
        /// <param name="listUpdateField">同步更新的字段及相关值</param>
        /// <param name="m">包含更新字段值的实体类</param>
        /// <returns></returns>
        bool Delete(int id, IList<string> listUpdateField, T m);
        /// <summary>
        /// 根据主键id逻辑删除一条数据(伪删除,需要传递删除标志字段以及相关值和需要同时修改的字段和字段值)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id"></param>
        /// <param name="listUpdateField">同步更新的字段及相关值</param>
        /// <returns></returns>
        bool Delete(int id, Dictionary<string, object> listUpdateField);
        /// <summary>
        /// 根据自定义条件逻辑删除一条数据(伪删除,需要传递删除标志字段以及相关值和需要同时修改的字段和字段值)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="strWhere">条件</param>
        /// <param name="paramFields">查询条件参数</param>
        /// <param name="listUpdateField">同步更新的字段及相关值</param>
        /// <returns></returns>
        bool Delete(string strWhere, Dictionary<string, object> paramFields, Dictionary<string, object> listUpdateField);
        #endregion

        /// <summary>
        /// 根据主键ID获取一条记录并返回对象实体
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id"></param>
        /// <returns></returns>
        T GetModel(int id);

        //bool Delete<T>(long id);
        //T GetModel<T>(long id);
    }
    public interface IBaseModelADO<T>:IBaseADO<T> where T : BaseModel, new()
    {
        #region 增删改
        /// <summary>
        /// 新增一条数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <returns></returns>
        long Add(T m, params string[] removeField);
        /// <summary>
        /// 根据自定义条件更新一条记录（不指定需要更新的字段时默认更新所有字段）
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="m"></param>
        /// <param name="updateField">需要更新的字段</param>
        /// <returns></returns>
        bool Update(T m, params string[] updateField);
        /// <summary>
        /// 根据自定义条件更新一条记录（参数集合名称不能与实体属性名称相同）（不指定需要更新的字段时默认更新所有字段）
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="m"></param>
        /// <param name="strWhere">查询条件</param>
        /// <param name="paramFields">参数集合</param>
        /// <param name="updateField">需要更新的字段</param>
        /// <returns></returns>
        bool Update(T m, string strWhere, Dictionary<string, object> paramFields, params string[] updateField);
        #endregion

        /// <summary>
        /// 根据传入的实体判断数据是否已经存在（有主键时，排除主键所在记录）
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="m"></param>
        /// <returns></returns>
        bool IsExists(T m);
        /// <summary>
        /// 根据传入的实体数据和条件字段名判断是否已经存在（有主键时，排除主键所在记录）
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="m"></param>
        /// <param name="strs">条件字段名数组</param>
        /// <returns></returns>
        bool IsExists(T m, params string[] listStrs);
        bool IsExists(T m, List<string[]> listStrs);
    }
}
